package net.lzzy.chapter427_1;
import net.lzzy.chapter426.Student;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class TestMap {
    public static void main(String[] args) {
        Student stu = new Student(1001,"张浩",88.6,21);
        Student stu1 = new Student(1002,"赵四",88.6,21);
        Student stu2 = new Student(1003,"王五",88.6,21);

        Map<Integer,Student> hashMap = new HashMap<>();
        hashMap.put(stu.getStuID(),stu);
        hashMap.put(stu1.getStuID(),stu1);
        hashMap.put(stu2.getStuID(),stu2);

        hashMap.forEach((id,name)-> System.out.println("key:"+id+" "+"value:"+ name+"\n"));

        Scanner scan = new Scanner(System.in);
        System.out.print("请输入你要查找的id：");
        Integer ID = scan.nextInt();

        System.out.println(hashMap.get(ID));
    }
}
